package com.erp.myAdapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import com.erp.bean.PackPieceBean
import com.erp.R
import com.erp.util.Myutil
import kotlinx.android.synthetic.main.lv_packpiece_item.view.*

/**
 * Created by Administrator on 2018/12/15/015.
 * 作者：刘洋
 */
class PackPieceKAdapter(private var mlist: List<PackPieceBean>, val mcontext: Context) : BaseAdapter() {
    private val minflater: LayoutInflater = LayoutInflater.from(mcontext)
    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        var v :View
        var h : Header
        if(convertView==null){
            v=minflater.inflate(R.layout.lv_packpiece_item,null)
            h= Header(v)
            v.tag=h
        }else{
            v=convertView
            h=v.tag as Header
        }
        val bean =mlist[position]
        Myutil.settv(bean.gangwei_name,h.TvGangweiName)
        Myutil.settv(bean.batch_name,h.TvBatchName)
        Myutil.settv(bean.cnum,h.TvCnum)
//        Myutil.settv(bean.mc1_mark,h.TvMark)
        Myutil.settv(bean.count,h.TvCount)
        Myutil.settv(Myutil.getdata(bean.ctime),h.TvCtime)
        Myutil.settv(bean.work_staff,h.TvYuanGong)
        return v
    }

    override fun getItem(position: Int): Any {
        return mlist.get(position)
    }

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

    override fun getCount(): Int {
       return mlist.size
    }

    class Header(var v : View){
        val TvGangweiName=v.TvGangweiName
        val TvBatchName=v.TvBatchName
        val TvCnum=v.TvCnum
        val TvMark=v.TvMark
        val TvCount=v.TvCount
        val TvCtime=v.TvCtime
        val TvYuanGong = v.TvYuanGong
    }
}